// source --> https://www.meccanotecnicapicena.net/wp-content/plugins/ddpro/js/ddp-admin.js?ver=5.2.18 var ddd_full_stop = 0; var json_counters_array = []; jQuery(document).ready(function(e) { // clipboard for report e("#ddp-success-report").hide(), new Clipboard("#ddp-copy-report").on("success", function() { e("#ddp-success-report").show(); }); jQuery('.wrap.ddp-assistant:not(.activated) a.nav-tab:not(.divi_den_pro_dashboard):not(.ddp_assistant_system_status):not(.ddp_assistant_help_faq):not(.ddp_start_here)').addClass('disabled'); jQuery('table.ddp-report-table td a, table.ddp-report-table th a').on('click touch', function(event) { event.preventDefault(); }); jQuery('#wp-ddp_wp_content-wrap').appendTo('tr#wp-ddp-column td'); setTimeout(function() { jQuery('.ddp-assistant>h1').insertBefore('h2.nav-tab-wrapper'); }, 100); function ddp_get_tinymce_content() { if (jQuery(".ddp_wl_settings #wp-content-wrap").hasClass("tmce-active")) { return tinyMCE.activeEditor.getContent(); } else { return jQuery('#html_text_area_id').val(); } } if (jQuery('.form-table.ddp_wl label input[name=ddp_plugin_name]').length > 0) { ddp_n = $('.form-table.ddp_wl label input[name=ddp_plugin_name]').val(); ddp_n = ddp_n.replace(/\s+/g, '_').toLowerCase(); ddp_url_path = window.location.pathname; $('.new_admin_url').html(window.location.protocol + '//' + window.location.hostname + ddp_url_path + '?page=' + ddp_n + '_dashboard_wl'); } jQuery('.form-table.ddp_wl label input[name=ddp_plugin_name]').on('keyup', function() { ddp_n = $(this).val(); ddp_n = ddp_n.replace(/\s+/g, '_').toLowerCase(); ddp_url_path = window.location.pathname; $('.new_admin_url').html(window.location.protocol + '//' + window.location.hostname + ddp_url_path + '?page=' + ddp_n + '_dashboard_wl'); }); // WL Submit Button jQuery('p.submit.ddp_wl.save_settings input').on('click touch', function(event) { event.preventDefault(); ddd_full_stop = 0; jQuery('.form-table.ddp_wl label input, .form-table.ddp_wl label textarea, #wp-ddp_wp_content-wrap').each(function() { //if($('input#ddp_wl').is(":checked")) { if ($(this).attr('id') !== 'wp-ddp_wp_content-wrap' && $(this).attr('name') !== 'ddp_plugin_icon') { if ($(this).val() === '') { ddd_full_stop = 1; $(this).addClass('not-filled'); $(this).siblings('.ddp-error-message').remove(); $(this).after('This field is required') } // else {ddd_full_stop = 0; // $(this).removeClass('not-filled'); // $(this).siblings('.ddp-error-message').remove();} } // } }); if (ddd_full_stop === 0) { $(this).next().hide(); jQuery('.form-table.ddp_wl label input, .form-table.ddp_wl label textarea, #wp-ddp_wp_content-wrap').each(function() { if ($(this).attr('id') === 'wp-ddp_wp_content-wrap') { ajax_option = 'ddp_wp_content'; ajax_val = tinyMCE.activeEditor.getContent(); } else { ajax_option = $(this).attr('name'); ajax_val = $(this).val(); } if (ajax_option === 'ddp_plugin_name') { var new_name = ajax_val; var new_link = ajax_val.replace(/\s+/g, '_').toLowerCase(); if (jQuery('input[name=ddp_wl]').is(":checked")) { redirect_link = window.location.pathname + '?page=' + new_link + '_dashboard_wl&tab=ddp_wl' } else redirect_link = window.location.pathname + '?page=divi_den_pro_dashboard&tab=ddp_wl'; if (jQuery('input[name=ddp_hide_menu]').is(":checked")) { redirect_link = window.location.pathname.replace('admin.php', ''); } } //if ( ddd_full_stop === 0) { jQuery.ajax({ type: 'POST', url: ajaxurl, data: 'action=ddp_update_option&ddp_option=' + ajax_option + '&ddp_option_val=' + ajax_val, success: function(data) { if (redirect_link) window.location.replace(redirect_link); else window.location.reload(); }, error: function(data) {} }); // } }); } else { $(this).next().show(); } }); jQuery('p input#submit_wl.submit_wl_disabled,p input#submit_wl.submit_wl_enabled').on('click', function(event) { event.preventDefault(); ddd_full_stop = 0; jQuery('.form-table.ddp_wl label input, .form-table.ddp_wl label textarea, #wp-ddp_wp_content-wrap').each(function() { //if($('input#ddp_wl').is(":checked")) { if ($(this).attr('id') !== 'wp-ddp_wp_content-wrap' && $(this).attr('name') !== 'ddp_plugin_icon') { if ($(this).val() === '') { ddd_full_stop = 1; $(this).addClass('not-filled'); $(this).siblings('.ddp-error-message').remove(); $(this).after('This field is required') } // else {ddd_full_stop = 0; // $(this).removeClass('not-filled'); // $(this).siblings('.ddp-error-message').remove();} } // } }); if (ddd_full_stop === 0) { $(this).next().hide(); $('.ddp_wl_hidden .et-box-content .et_pb_button_slider').click(); $('.submit.ddp_wl.save_settings input').click(); } else { $(this).next().show(); } }); }); jQuery(document).ready(function($) { $('#ddp-preview-window').insertAfter('body > :last-child'); jQuery.fn.center = function() { this.css("position", "absolute"); this.css("top", (jQuery(window).height() - this.height()) / 2 + jQuery(window).scrollTop() + "px"); this.css("left", (jQuery(window).width() - this.width()) / 2 + jQuery(window).scrollLeft() + "px"); return this; } $('#ddp-preview').on('click', function() { jQuery("#ddp-preview-window").center(); $('#ddp-preview-window').show(); }); $('#ddp-preview-close').on('click', function() { $('#ddp-preview-window').hide(); }); // main function function onIframeLoad() { setTimeout(function() { $('iframe#ondemanIframe').on('load', function() { var frame = document.getElementById('ondemanIframe'); // remove divi loading animation $('#et_pb_loading_animation').remove(); jQuery.ajax({ type: 'GET', url: ajaxurl, data: 'action=ddp_get_option', success: function(data) { var ddp_sp_enable = data + ''; if (ddp_sp_enable === 'enabled') { frame.contentWindow.postMessage('pro_membership_activated', '*'); } else { frame.contentWindow.postMessage('pro_membership_deactivated', '*'); } } }); // function to get post id from the url parameter 'post' function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for (var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } var post_id = getUrlVars()["post"]; // Create IE + others compatible event handler var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; var eventer = window[eventMethod]; var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; // Show featured images for sections - backend divi builder if ($('ul.et_pb_saved_layouts_list').length > 0) { $('ul.et_pb_saved_layouts_list li:not(.added_image)').each(function() { this_title = $(this).find('a').text(); this_class = this_title.replace(/-+/g, '').replace(/\s+/g, '-').toLowerCase(); $(this).addClass(this_class); jQuery.ajax({ type: 'POST', url: ajaxurl, data: 'action=ddp_show_featured_image&ddp_title_image=' + this_title, success: function(data) { if (data !== '') { img_link = data.substring(data.indexOf("|") + 1); img_post_title = data.replace(img_link, '').replace('|', ''); $('ul.et_pb_saved_layouts_list li:not(.with-image)').each(function() { this_title = $(this).find('a').text(); if (this_title === img_post_title) { $(this).find('a').before(''); $(this).addClass('with-image'); } }); } }, error: function(data) { } }); $(this).addClass('added_image'); }); //$('ul.et_pb_saved_layouts_list').addClass('ddp_images_sent'); } // Show featured images for sections - visual divi builder setInterval(function() { if ($('div.et-fb-settings-options-tab-modules_library ul:not(.ddp_images_sent)').length > 0) { $('div.et-fb-settings-options-tab-modules_library ul li:not(.added_image):not(.with-image)').each(function() { this_title = $(this).find('span.et_module_title').text().trim(); this_class = this_title.replace(/-+/g, '').replace(/\s+/g, '-').toLowerCase(); $(this).addClass(this_class); jQuery.ajax({ type: 'POST', url: ajaxurl, data: 'action=ddp_show_featured_image&ddp_title_image=' + this_title, success: function(data) { if (data !== '') { img_link = data.substring(data.indexOf("|") + 1); img_post_title = data.replace(img_link, '').replace('|', ''); $('div.et-fb-settings-options-tab-modules_library ul li:not(.with-image)').each(function() { this_title = $(this).find('span.et_module_title').text().trim(); if (this_title === img_post_title && $(this).find('img.ddp_preview').length === 0) { $(this).find('span.et_module_title').after(''); $(this).addClass('with-image'); } }); } }, error: function(data) {} }); $(this).addClass('added_image'); }); //$('div.et-fb-settings-options-tab-modules_library ul').addClass('ddp_images_sent'); } }, 1000); var global_json_counter = 0; var json_counter = 0; // Listen to message from child window eventer(messageEvent, function(e) { if (e.origin === 'https://ondemand.divi-den.com') { var response; if (jQuery.type(e.data) === 'string') { // check if the response is text if (~e.data.indexOf('context')) { // if the response is a divi json file var ddp_replace_content = 'off'; // if (jQuery('.ddp-replace-content input').attr("checked") === 'checked') { // ddp_replace_content = 'on'; // } if (jQuery('#et_pb_main_container > .et_pb_section .et_pb_module_block').length <= 0) { ddp_replace_content = 'on'; } response = jQuery.parseJSON(e.data); if (response) { if (!$(frame).hasClass('settingsIframe') && !$(frame).hasClass('vbIframe') && response.context == 'et_builder') { // console.log('LOADING LAYOUT'); layout = JSON.stringify(response); //console.log('layout'); //console.log(layout); var ddp_list = jQuery('.et-pb-all-modules-tab .et-pb-load-layouts'); var ddp_li = ddp_list.children('li').last().clone(true); ddp_li.addClass('layout_here'); ddp_li.appendTo(ddp_list); jQuery('.layout_here').data('layout_id', { layout: layout, replace_content: ddp_replace_content }); jQuery('.layout_here .et_pb_layout_button_load').click(); } else if (response.context == 'et_builder_layouts' || $(frame).hasClass('settingsIframe')) { response_data = encodeURIComponent(JSON.stringify(response.data)); // import to library // console.log('IMPORT'); jQuery.ajax({ type: 'POST', url: ajaxurl, // processData: false, data: 'action=ddp_import_posts&posts=' + response_data, success: function(data) { if ($("div.sectionSaved").length === 0) { $('.ddp-tab-section, .ddp-tab-module').html('
\

Success! Your section/module is being saved to your local Divi library.

\

Choose your next step...

\

1. Find new modules and save to your library

\ Find New Pro Modules\

2. Begin editing - Use the "Add From Library" tab to load sections/modules from local Divi Library

\ To Continue - Save and Reload Page\ (please do it manually if you are in Divi Visual Builder)\
'); $('body .ddp-tab-section a.ddp_reload, body .ddp-tab-module a.ddp_reload').on('click', function(e) { e.preventDefault(); $('div.sectionSaved').html('

Reloading...

'); $('input.button-primary#publish').click(); $('button.et-fb-button--publish').click(); $('li#wp-admin-bar-et-disable-visual-builder a.ab-item').click(); }); var ddp_rand = Math.floor((Math.random() * 1000000) + 1); if (ddp_wl_options_for_js.ddp_status === 'enabled') { ddp_sections_link = 'https://ondemand.divi-den.com/sections-search-api-ljljdfre935/?uid=' + ddp_rand; ddp_modules_link = 'https://ondemand.divi-den.com/modules-search-api-fdge43y/?uid=' + ddp_rand; } else { ddp_sections_link = 'https://ondemand.divi-den.com/sections-search-no-api-asdfv324/?uid=' + ddp_rand; ddp_modules_link = 'https://ondemand.divi-den.com/modules-search-no-api-33jwer3/?uid=' + ddp_rand; } $('body .ddp-tab-section a.ddp_close').on('click', function(e) { e.preventDefault(); $('div.sectionSaved').html('

Loading...

'); $('.ddp-tab-section').html(''); onIframeLoad(); }); $('body .ddp-tab-module a.ddp_close').on('click', function(e) { e.preventDefault(); $('div.sectionSaved').html('

Loading...

'); $('.ddp-tab-module').html(''); onIframeLoad(); }); } $('body .ddp-assistant .loaded_message').show(); setTimeout(function() { $('body .ddp-assistant .loaded_message').hide(); }, 5500); }, error: function(data) { console.log(data); } }); } // if(response.context == 'et_builder_layouts') } // if (response) } // if (~e.data.indexOf('context')) else if (~e.data.indexOf('.')) { // if the response is a css file console.log('CSS'); $('input#_et_pb_custom_css').val(e.data); } else if (~e.data.indexOf(',jpg') || ~e.data.indexOf(',png')) { //a featured image link console.log('IMAGE'); ddp_featured_image_url = e.data.replace(/\,/g, '.') setTimeout(function() { jQuery.ajax({ type: 'POST', url: ajaxurl, // processData: false, data: 'action=ddp_import_featured_image&ddp_featured_image=' + ddp_featured_image_url, success: function(data) {}, error: function(data) {} }); }, 1000); //setTimeout(function(){ } } //if jQuery.type(e.data) === 'string' } //if (e.origin === 'https://ondemand.divi-den.com') { }, false); // eventer(messageEvent, function(e) { }); // $('iframe#ondemanIframe').on('load', function() }, 200); } //function onIframeLoad() $('body .ddp-assistant .loaded_message span.close').on('click', function() { $('body .ddp-assistant .loaded_message').hide(); }); jQuery(document).on('keyup', function(evt) { if (evt.keyCode == 27) { //console.log('Escape pressed'); $('body .ddp-assistant .loaded_message').hide(); } }); if (typeof ajaxurl === 'undefined') { ajaxurl = ddp_wl_options_for_js.ddp_ajax_url; } if($('body').hasClass('et-fb') || $('body').hasClass('wp-admin')) { // isert Divi Den Pro Tabs to Divi builder jQuery.ajax({ type: 'GET', url: ajaxurl, data: 'action=ddp_get_option_wl', success: function(data) { var ddp_enable = data + ''; if (ddp_enable === 'disabled') { // check if the DDD is enabled in settings onIframeLoad(); // our main function // Insert layout from library $(document).on('mouseup', '.et-pb-layout-buttons-load', function() { setTimeout(function() { var ddp_rand = Math.floor((Math.random() * 1000000) + 1); if (ddp_wl_options_for_js.ddp_status === 'enabled') { ddp_layouts_link = 'https://ondemand.divi-den.com/new-api-layouts-search-ghaser65/?uid=' + ddp_rand; } else { ddp_layouts_link = 'https://ondemand.divi-den.com/new-no-api-layouts-search-dngfh4q2/?uid=' + ddp_rand; } var tabbar = $('.et-pb-saved-modules-switcher'); if (ddp_wl_options_for_js.ddp_plugin_setting_tab_position === 'on') { if (tabbar.length) { tabbar.append('
  • ' + ddp_wl_options_for_js.ddp_wl_pn_for_js + '
  • '); $(".et_pb_modal_settings").append('
    \

    \ Important: if you\'re replacing the content, please manually clear the layout and update the page, then load the new layout.

    \
    '); } } else { $('li.et-pb-options-tabs-links-active').removeClass('et-pb-options-tabs-links-active'); $('div.active-container').removeClass('active-container').css('opacity', 0); tabbar.prepend(''); $(".et_pb_modal_settings").append('
    \

    \ Important: if you\'re replacing the content, please manually clear the layout and update the page, then load the new layout.

    \
    '); } }, 200); onIframeLoad(); }); //Insert section from library $(document).on('mouseup', '.et-pb-section-add-saved', function() { setTimeout(function() { jQuery('.et_pb_modal_settings.et_pb_modal_no_tabs').removeClass('et_pb_modal_no_tabs'); var ddp_rand = Math.floor((Math.random() * 1000000) + 1); if (ddp_wl_options_for_js.ddp_status === 'enabled') { ddp_sections_link = 'https://ondemand.divi-den.com/sections-search-api-ljljdfre935/?uid=' + ddp_rand; } else ddp_sections_link = 'https://ondemand.divi-den.com/sections-search-no-api-asdfv324/?uid=' + ddp_rand; if (ddp_wl_options_for_js.ddp_plugin_setting_tab_position === 'on') { jQuery('.et_pb_modal_settings_container h3').after(' \ \
    '); } // if ddp_wl_options_for_js.ddp_plugin_setting_tab_position else { $('li.et-pb-options-tabs-links-active').removeClass('et-pb-options-tabs-links-active'); $('div.active-container').removeClass('active-container').css('opacity', 0); jQuery('.et_pb_modal_settings_container h3').after(' \ \
    '); } }, 200); onIframeLoad(); }); //Insert modules from library $(document).on('mouseup', '.et-pb-column .et-pb-insert-module', function() { setTimeout(function() { jQuery('.et_pb_modal_settings.et_pb_modal_no_tabs').removeClass('et_pb_modal_no_tabs'); var ddp_rand = Math.floor((Math.random() * 1000000) + 1); if (ddp_wl_options_for_js.ddp_status === 'enabled') { ddp_modules_link = 'https://ondemand.divi-den.com/modules-search-api-fdge43y/?uid=' + ddp_rand; } else ddp_modules_link = 'https://ondemand.divi-den.com/modules-search-no-api-33jwer3/?uid=' + ddp_rand; // $('li.et-pb-options-tabs-links-active').removeClass('et-pb-options-tabs-links-active'); // $('div.active-container').removeClass('active-container').css('opacity', 0); $('.et-pb-options-tabs-links.et-pb-saved-modules-switcher').remove(); if (ddp_wl_options_for_js.ddp_plugin_setting_tab_position === 'on') { jQuery('.et_pb_modal_settings_container h3').after(' \ \
    \ '); } else { // $('.et-pb-options-tabs-links.et-pb-saved-modules-switcher').remove(); $('li.et-pb-options-tabs-links-active').removeClass('et-pb-options-tabs-links-active'); $('div.active-container').removeClass('active-container').css('opacity', 0); jQuery('.et_pb_modal_settings_container h3').after(' \ \
    \ '); } }, 200); onIframeLoad(); }); setInterval(function() { // VISUAL BUILDER SECTIONS and MODULES if (($('a.modules_all').text() == 'New Section' || $('a.modules_all').text() == 'New Module') && $('.ddp').length <= 0) { $('#et-fb-settings-column').css('overflow', 'hidden'); var ddp_rand = Math.floor((Math.random() * 1000000) + 1); if (ddp_wl_options_for_js.ddp_status === 'enabled') { ddp_sections_link = 'https://ondemand.divi-den.com/sections-search-api-ljljdfre935/?uid=' + ddp_rand; ddp_modules_link = 'https://ondemand.divi-den.com/modules-search-api-fdge43y/?uid=' + ddp_rand; } else { ddp_sections_link = 'https://ondemand.divi-den.com/sections-search-no-api-asdfv324/?uid=' + ddp_rand; ddp_modules_link = 'https://ondemand.divi-den.com/modules-search-no-api-33jwer3/?uid=' + ddp_rand; } if (ddp_wl_options_for_js.ddp_plugin_setting_tab_position === 'on') { $('a.modules_all').parents('.et-fb-settings-tabs-nav').append('
  • \ ' + ddp_wl_options_for_js.ddp_wl_pn_for_js + '
  • '); if ($('a.modules_all').text() == 'New Section') { $(".et-fb-settings-options-wrap > .et-fb-settings-options").append('
    \
    '); } if ($('a.modules_all').text() == 'New Module') { $(".et-fb-settings-options-wrap > .et-fb-settings-options").append('
    \
    '); } var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + ' width: 400px; min-height: auto; left: 38%;') } else { $('a.modules_all').parents('.et-fb-settings-tabs-nav').prepend('
  • \ ' + ddp_wl_options_for_js.ddp_wl_pn_for_js + '
  • '); if ($('a.modules_all').text() == 'New Section') { $(".et-fb-settings-options-wrap > .et-fb-settings-options").prepend('
    \
    '); } if ($('a.modules_all').text() == 'New Module') { $(".et-fb-settings-options-wrap > .et-fb-settings-options").prepend('
    \
    '); } $(".ddp-tab-section").siblings('div').removeClass('et-fb-settings-options-tab--active'); $('.et-fb-settings-tabs-nav li.ddp a').parent('li').siblings().removeClass('et-fb-settings-tabs-nav-item--active'); $('.et-fb-settings-options-wrap').attr('style', 'max-height: 100% !important; max-height: 100% !important; height: 100% !important;'); var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + ' width: 80%; min-height: 650px; left: 10%;') $('.ddp').parents('.et-fb-settings-tabs-nav').addClass('ddp-tab-parent'); $('.ddp-tab-section').parents('div.et-fb-settings-options').removeClass('ddp-option-parent'); } $('.et-fb-settings-options-wrap').attr('style', 'max-height: 100% !important; max-height: 100% !important; height: 100% !important;'); $('.et-fb-main-settings--add_new_module .et-fb-settings-tabs-nav li:not(.ddp) a').on('click', function() { //console.log('Click on ather tab'); // $('li.et-fb-settings-tabs-nav-item--active').removeClass('et-fb-settings-tabs-nav-item--active'); $(".ddp-tab-section").removeClass('et-fb-settings-options-tab--active'); $(this).parent('li').siblings('li').removeClass('et-fb-settings-tabs-nav-item--active'); $(this).parent('li').addClass('et-fb-settings-tabs-nav-item--active'); $(this).parents('div.et-fb-settings-options').removeClass('ddp-option-parent'); $('.et-fb-settings-options-wrap').removeAttr('style'); var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + ' width: 400px; min-height: auto; left: 38%;') $(this).parents('.et-fb-settings-tabs-nav').removeClass('ddp-tab-parent'); }); $('.et-fb-main-settings--add_new_module .et-fb-settings-tabs-nav li.ddp a').on('click', function(e) { e.preventDefault(); //console.log('Click on DDP'); $(this).parent('li').siblings().removeClass('et-fb-settings-tabs-nav-item--active'); $(".ddp-tab-section").siblings('div').removeClass('et-fb-settings-options-tab--active'); $(this).parent('li').addClass('et-fb-settings-tabs-nav-item--active'); $(".ddp-tab-section").addClass('et-fb-settings-options-tab--active'); $(".ddp-tab-section").parents('div.et-fb-settings-options-wrap').addClass('ddp-option-parent'); var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + ' width: 80%; min-height: 650px; left: 10%;'); $('.et-fb-settings-options-wrap').attr('style', 'max-height: 100% !important; height: 100% !important;'); $(this).parents('.et-fb-settings-tabs-nav').addClass('ddp-tab-parent'); }); onIframeLoad(); } if ($('.et-fb-module-settings li[data-open_tab="ddp-tab"]').length > 0) { // console.log('styles ' + styles); if (!$('.et-fb-module-settings li[data-open_tab="ddp-tab"]').hasClass('et-fb-settings-tabs-nav-item--active')) { // console.log('Another tab'); var new_style = " width: 400px; min-height: auto; left: 38%;"; var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); if (attr_style && ~attr_style.indexOf(new_style)) { attr_style = attr_style.replace(/ width: 400px; min-height: auto; left: 38%;/, ''); attr_style = attr_style.replace(/ width: 80%; min-height: 650px; left: 10%;/g, ''); } $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + new_style); $('.et-fb-settings-options-wrap').removeAttr('style'); $('.et-fb-settings-tabs-nav').removeClass('ddp-tab-parent'); this_tab_text = $('li.et-fb-settings-tabs-nav-item--active').text(); if (this_tab_text === 'New Section') { $('.et-fb-settings-options-wrap .et-fb-settings-options .et-fb-settings-options-tab-modules_all').show(); $('.et-fb-settings-options-wrap .et-fb-settings-options .et-fb-settings-options-tab-modules_library').hide(); $('.et-fb-settings-options-wrap').attr('style', 'max-height: 130px !important; height: 100% !important;'); var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); attr_style = attr_style.replace(/min-height: auto;/g, ''); attr_style = attr_style.replace(/min-height: 400px;/g, ''); if (attr_style && attr_style.indexOf('min-height: 130px') < 1) $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + ' min-height: 130px;') } if (this_tab_text === 'Add From Library') { $('.et-fb-settings-options-wrap .et-fb-settings-options .et-fb-settings-options-tab-modules_all').hide(); $('.et-fb-settings-options-wrap .et-fb-settings-options .et-fb-settings-options-tab-modules_library').show(); $('.et-fb-settings-options-wrap').css('overflow-y', 'auto'); $('.et-fb-settings-options-wrap').attr('style', 'max-height: 500px !important; height: 100% !important;'); var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); attr_style = attr_style.replace(/min-height: auto;/g, ''); attr_style = attr_style.replace(/min-height: 130px;/g, ''); if (attr_style && attr_style.indexOf('min-height: 400px') < 1) $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + ' min-height: 400px;') } if (this_tab_text === 'New Module') { $('.et-fb-settings-options-wrap .et-fb-settings-options .et-fb-settings-options-tab-modules_all').show(); $('.et-fb-settings-options-wrap .et-fb-settings-options .et-fb-settings-options-tab-modules_library').hide(); $('.et-fb-settings-options-wrap').css('overflow-y', 'auto'); $('.et-fb-settings-options-wrap').attr('style', 'max-height: 500px !important; height: 100% !important;'); var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); attr_style = attr_style.replace(/min-height: auto;/g, ''); attr_style = attr_style.replace(/min-height: 130px;/g, ''); if (attr_style && attr_style.indexOf('min-height: 400px') < 1) $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + ' min-height: 400px;') } } else { // console.log('DDP tab'); var attr_style = $('a.modules_all').parents('#et-fb-settings-column').attr('style'); var new_style = " width: 80%; min-height: 650px; left: 10%;"; attr_style = attr_style.replace(/ width: 400px; min-height: auto; left: 38%;/g, ''); if (attr_style && ~attr_style.indexOf(new_style)) { //attr_style = attr_style.replace(/ width: 400px; min-height: auto; left: 38%;/g, ''); attr_style = attr_style.replace(/ width: 80%; min-height: 650px; left: 10%;/, ''); } // console.log('attr_style '+attr_style); $('a.modules_all').parents('#et-fb-settings-column').attr('style', attr_style + ' width: 80%; min-height: 650px; left: 10%;') $('.et-fb-settings-options-wrap').attr('style', 'max-height: 100% !important; min-height: 100% !important; height: 100% !important;'); $(this).parents('.et-fb-settings-tabs-nav').addClass('ddp-tab-parent'); $('.et-fb-settings-options-wrap .et-fb-settings-options .et-fb-settings-options-tab-modules_all').hide(); $('.et-fb-settings-options-wrap .et-fb-settings-options .et-fb-settings-options-tab-modules_library').hide(); } } }, 500); } else onIframeLoad(); //if (ddp_enable == 'enabled') }, error: function(data) {} }); // ajax } //if($('body').hasClass('et-fb') || $('body').hasClass('wp-admin')) setInterval(function() { if ($('iframe#ondemandIframe.settingsIframe').length) { // console.log('ondemandIframe.settingsIframe'); onIframeLoad(); } }, 1000); // Yes - No button UI $('.ddp-assistant .yes_no_button').each(function() { var $checkbox = $(this); var value = $checkbox.is(':checked'); var state = value ? 'et_pb_on_state' : 'et_pb_off_state'; var $template = $($('#epanel-yes-no-button-template').html()).find('.et_pb_yes_no_button').addClass(state); $checkbox.hide().after($template); if ('et_pb_static_css_file' === $checkbox.attr('id')) { $checkbox .parent() .addClass(state) .next() .addClass('et_pb_clear_static_css') .on('click', function() { epanel_clear_static_css(false, true); }); if (!value) { $checkbox.parents('.et-epanel-box').next().hide(); } } }); // Save settings button $('.ddp_settings.save_settings input#submit').on('click', function(e) { e.preventDefault(); $(".ddp-archive-settings .et-epanel-box select").each(function() { var this_option = $(this).attr('id'); var this_val = $(this).val(); //console.log(this_option + " " + this_val); jQuery.ajax({ type: 'POST', url: ajaxurl, data: 'action=ddp_update_option&ddp_option=' + this_option + '&ddp_option_val=' + this_val, success: function(data) { window.location.reload(); }, error: function(data) {} }); }); }); // Enable / Disable ddp button $('.ddp-assistant .et-box-content').on('click', '.et_pb_yes_no_button', function(e) { e.preventDefault(); var $click_area = $(this), $box_content = $click_area.parents('.et-box-content'), $checkbox = $box_content.find('input[type="checkbox"]'), $state = $box_content.find('.et_pb_yes_no_button'); $ddp_option = $box_content.find('input').attr('name'); $state.toggleClass('et_pb_on_state et_pb_off_state'); if ($checkbox.is(':checked')) { $checkbox.prop('checked', false); } else { $checkbox.prop('checked', true); } if ($click_area.hasClass('et_pb_on_state')) { ajax_value = 'enabled'; if ($click_area.hasClass('ddp_enable')) { var ddp_rand = Math.floor((Math.random() * 1000000) + 1); if (ddp_wl_options_for_js.ddp_status === 'enabled') { ddp_layouts_link = 'https://ondemand.divi-den.com/new-api-layouts-search-ghaser65/?uid=' + ddp_rand; } else { ddp_layouts_link = 'https://ondemand.divi-den.com/new-no-api-layouts-search-dngfh4q2/?uid=' + ddp_rand; } $('').insertAfter('.ddp-assistant hr'); onIframeLoad(); } } else { ajax_value = 'disabled'; //if ($click_area.hasClass('ddp_enable')) { $('.ddp-assistant iframe#ondemanIframe').remove(); } } if (ddd_full_stop === 0) { // update ddp enable / disable option jQuery.ajax({ type: 'POST', url: ajaxurl, data: 'action=ddp_update_option&ddp_option=' + $ddp_option + '&ddp_option_val=' + ajax_value, success: function(data) {}, error: function(data) {} }); } }); $('.ddp-accordion .ddp-accordion-header').click(function() { //Expand or collapse this panel $(this).next('.ddp-accordion-content').slideToggle('fast'); $(this).parent('.ddp-accordion').toggleClass('closed').toggleClass('opened'); $('.ddp-accordion.opened h3 span').html('-'); $('.ddp-accordion.closed h3 span').html('+'); //Hide the other panels // $(".ddp-accordion-content").not($(this).next('.ddp-accordion-content')).slideUp('fast'); }); setTimeout(function() { if ($('.ddp-assistant.activated h2.nav-tab-wrapper').length > 0) { $('div[data-dismissible=disable-ddpro-cache-notice-forever]').insertAfter('.ddp-assistant.activated h2.nav-tab-wrapper'); $('div[data-dismissible=disable-ddpro-cache-notice-forever]').show(); } }, 300); setInterval(function() { if ($('iframe#ondemanIframe').length > 0) { $('div[data-dismissible=disable-ddpro-cache-notice-forever]:not(.shown)').insertBefore('iframe#ondemanIframe'); $('div[data-dismissible=disable-ddpro-cache-notice-forever]:not(.shown)').show(); $('div[data-dismissible=disable-ddpro-cache-notice-forever]').addClass('shown'); } }, 100); $('input[name="ddp_plugin_name"]').alphanum({ allowSpace: true, // Allow the space character allowUpper: true // Allow Upper Case characters }); // PLUGIN SETTING // tap position if ($("input#ddp_plugin_setting_tab_position").length > 0) { jQuery.ajax({ type: 'GET', url: ajaxurl, data: 'action=ddp_get_option_ddp_plugin_setting_tab_position', success: function(data) { // console.log(data); if ((data) === 'on') $("input#ddp_plugin_setting_tab_position").attr('checked', 'checked'); else $("input#ddp_plugin_setting_tab_position").removeAttr('checked'); }, error: function(data) {} }); $("input#ddp_plugin_setting_tab_position").on('change', function() { var this_option = $(this).attr('id'); if ($(this).attr('checked') === 'checked') $(this).val('on'); else $(this).val('off'); var this_val = $(this).val(); jQuery.ajax({ type: 'POST', url: ajaxurl, data: 'action=ddp_update_option&ddp_option=' + this_option + '&ddp_option_val=' + this_val, success: function(data) { //console.log(this_option + ": " + this_val); }, error: function(data) {} }); }); // $("input#ddp-setting-tab-position").on } //if( $("input#ddp_plugin_setting_tap_position").length > 0) }); //jQuery(document).ready(function($);